<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title></title>
<link rel="stylesheet" href="__PUBLIC__/styles/pintuer.css">
<link rel="stylesheet" href="__PUBLIC__/styles/admin.css">
<link rel="stylesheet" href="__PUBLIC__/vendor/fontawesome/css/font-awesome.css" />
<link rel="stylesheet" href="__PUBLIC__/vendor/metisMenu/dist/metisMenu.css" />
<link rel="stylesheet" href="__PUBLIC__/vendor/animate.css/animate.css" />
<link rel="stylesheet" href="__PUBLIC__/vendor/bootstrap/dist/css/bootstrap.css" />
<link rel="stylesheet" href="__PUBLIC__/vendor/sweetalert/lib/sweet-alert.css" />
<link href="__UPLOADIFY__/common.css" rel="stylesheet" type="text/css" />
<!-- App styles -->
<link rel="stylesheet" href="__PUBLIC__/fonts/pe-icon-7-stroke/css/pe-icon-7-stroke.css" />
<link rel="stylesheet" href="__PUBLIC__/fonts/pe-icon-7-stroke/css/helper.css" />
<link rel="stylesheet" href="__PUBLIC__/styles/style.css">
<script src="__PUBLIC__/scripts/jquery.js"></script>
<script src="__PUBLIC__/scripts/pintuer.js"></script>
<script src="__PUBLIC__/vendor/jquery/dist/jquery.min.js"></script>
<script src="__LAYER__/layer.js"></script>
<script src="__PUBLIC__/vendor/bootstrap/dist/js/bootstrap.min.js"></script>
<!--<script type="text/javascript" src="__UPLOADIFY__/jquery.uploadify.min.js"></script>-->
  <script src="__AJAXFILEUPLOAD__/ajaxfileupload.js" type="text/javascript"></script>
</head>
<body>
<div class="panel admin-panel">
  <div class="padding border-bottom">
    <button type="button" class="button border-yellow" data-toggle="modal" data-target="#myModal"><span class="icon-plus-square-o"></span> 添加医疗成员</button>
      小组编号(其他成员输入该编号可加入您的小组):{$group_info.label}
  </div>
  <table class="table table-hover text-center">
    <tr>
      <th width="5%">头像</th>
      <th width="15%">姓名</th>
      <th width="10%">技能标签</th>
      <th width="10%">操作</th>
    </tr>
    <foreach name="doctors" item="row">
      <tr>
        <td><img src="{$row.headurl}" width="50px" height="50px" style="border-radius: 50%"></td>
        <td>{$row.name}</td>
        <td>{$row.skill}</td>
        <td><div class="button-group"> <a class="button border-red" href="javascript:void(0)" onclick="return del({$row['user_id']},{$group_info['id']})"><span class="icon-trash-o"></span> 删除</a> </div></td>
      </tr>
    </foreach>
  </table>
</div>

<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
        </button>
        <h4 class="modal-title" id="myModalLabel">
          邀请成员加入
        </h4>
        注：该成员必须通过医生审核才能邀请
      </div>
      <div class="modal-body">
        输入成员的手机号：<input type="text" id="member-phone">
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭
        </button>
        <button type="button" id="acceptprotocol" class="btn btn-primary">
          确定选择
        </button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal -->
</div>

<script type="text/javascript">
function del(id,mid){
	if(confirm("您确定要删除该成员吗?")){
        $.ajax({
          type: "post",
          url:"{:U('Auditing/Index/ajaxDeleteMember')}",
          async: true,
          dataType: 'json',
          data: {
             'user_id':id,
             'group_id':mid
          },
          success: function(data) {
             if(data.status == '1'){
                layer.msg(data.msg, {icon: 6});
                setTimeout(function () {
                   location.reload();
                },2000)
             }else {
                layer.msg(data.msg, {icon: 5});
             }
          },
          error: function(xhr, type, errorThrown) {
            mui.toast("网络连接失败");
          }
        });
	}


}
$("#acceptprotocol").click(function(){
  $(".icheckbox_square-green").addClass("checked");
  $(".approveCheck").attr("checked",true);
  $('#myModal').modal('hide');
  //获取推送用户手机号
  var phone = $('#member-phone').val();
  layer.msg('请等待', {
    icon: 16
    ,shade: 0.1
  });
  //先获取当前手机用户的名字
  $.getJSON("{:U('Index/ajaxInviteMember')}",{phone:phone,flag:'A',group_id:{$group_info['id']}},function (response) {
    if(response.status == '1'){
      //成功后给与弹出验证是否要邀请***加入
        if(confirm("即将邀请成员："+response.name+"，加入您的小组吗？")){
          layer.msg('请等待', {
            icon: 16
            ,shade: 0.1
          });
          //确定后再调用该接口
            $.getJSON("{:U('Index/ajaxInviteMember')}",{phone:phone,flag:'B',group_id:{$group_info['id']}},function (res){
              if(res.status == '2'){
                layer.msg(res.msg, {icon: 6});
                setTimeout(function () {
                  location.reload();
                },2000)
              }else {
                layer.msg(res.msg, {icon: 5});
              }
            })
        }
//        layer.msg(response.msg, {icon: 6});
//        setTimeout(function () {
//          location.reload();
//        },2000)
    }else {
        layer.msg(response.msg, {icon: 5});
    }
  });
})
</script>
<div class="panel admin-panel margin-top">
  <div class="panel-head" id="add"><strong><span class="icon-pencil-square-o"></span>资料管理</strong></div>
  <div class="body-content">
    <form method="post" class="form-x" action="{:U()}">
      <div class="form-group">
        <div class="label">
          <label>*小组名称：</label>
        </div>
        <div class="field">
          <input type="text" id="group-name" class="input w50" name="name" value="{$group_info['name']}" />
          <div class="tips"></div>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>*服务价格：</label>
        </div>
        <div class="field">
          <input type="text" id="group-price" class="input w50" name="prise" value="{$group_info['prise']}" />
          <div class="tipss">以元/天、元/次为单位</div>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>*联系电话：</label>
        </div>
        <div class="field">
          <input type="text" id="group-phone" class="input w50" name="phone" value="{$group_info['phone']}" />
          <div class="tips"></div>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>微信：</label>
        </div>
        <div class="field">
          <input type="text" id="group-wechat" class="input w50" name="wechat" value="{$group_info['wechat']}" />
          <div class="tips"></div>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>技能标签：</label>
        </div>
        <div class="field">
          <input type="text" id="group-skill" class="input w50" name="skill" value="{$group_info['skill']}" />
          <div class="tipss">多项请用逗号‘，’隔开</div>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>服务地区（重庆）：</label>
        </div>
        <div class="field">
          <foreach name="ares_c" item="row">
            <label style="font-weight: normal"><input type="checkbox" class="w50" name="server_are[]" value="{$row.id}" <in name="row['id']" value="$area_ids">checked="checked"</in> />{$row.title}</label>
          </foreach>
          <div class="tips"></div>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>服务地区（三亚）：</label>
        </div>
        <div class="field">
          <foreach name="ares_s" item="row">
            <label style="font-weight: normal"><input type="checkbox" class="w50" name="server_are[]" value="{$row.id}" <in name="row['id']" value="$area_ids">checked="checked"</in> />{$row.title}</label>
          </foreach>
          <div class="tips"></div>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label>小组logo：：</label>
        </div>
        <div class="field">
          <input type="file" name="headlog" class="button bg-blue margin-left" id="logo-upload" style="float:left;" accept="image/*"><button type="button" id="dianji">点击上传</button>
          <div class="tipss" id="logo-preview"><img src="{$group_info.headurl}" width="60px" height="60px" style="border-radius: 50%"></div>
          <input type="hidden" id="head-logo" name="headurl" value="{$group_info.headurl}">
        </div>
      </div>
      <!--<div class="form-group">-->
        <!--<div class="label">-->
          <!--<label>小组logo：</label>-->
        <!--</div>-->
        <!--<div class="field">-->
          <!--<input type="file" class="button bg-blue margin-left" id="logo-upload" style="float:left;">-->
          <!--<div class="tipss" id="logo-preview"><img src="{$group_info.headurl}" width="60px" height="60px" style="border-radius: 50%"></div>-->
          <!--<input type="hidden" id="head-logo" name="headurl" value="{$group_info.headurl}">-->
        <!--</div>-->
      <!--</div>-->
      <div class="form-group">
        <div class="label">
          <label>小组简介：</label>
        </div>
        <div class="field">
          <textarea type="text" class="input w50" name="content" style="height:150px;" placeholder="小组介绍">{$group_info['content']}</textarea>
        </div>
      </div>
      <div class="form-group">
        <div class="label">
          <label></label>
        </div>
        <div class="field">
          <div id="img-url"></div>
            <input type="hidden" name="id" value="{$group_info['id']}">
          <button onclick="return confirm('确定修改小组信息吗？')" class="button bg-main icon-check-square-o" id="submit-content" type="submit"> 提交</button>
        </div>
      </div>
    </form>
  </div>
</div>

<script>

    $("#dianji").click(function () {
      layer.msg('请等待', {
        icon: 16
        ,shade: 0.1
      });
      $.ajaxFileUpload({
        url: '{:U("Auditing/Index/ajaxHeadImg")}', //用于文件上传的服务器端请求地址
        secureuri: false, //是否需要安全协议，一般设置为false
        fileElementId: 'logo-upload', //文件上传域的ID
        dataType: 'JSON', //返回值类型 一般设置为json
        success: function (data, status)  //服务器成功响应处理函数
        {
          var res = eval("("+data+")");
          if(res.status == '1'){
            var file_url = res.url;
  //                    //将图片路径放入到隐藏域中
            $('#head-logo').val(file_url);
            $('#logo-preview').html('<img src="'+file_url+'" width="60px" height="60px" style="border-radius: 50%">');
            layer.msg(res.msg, {icon: 6});
          }else{
            layer.msg(res.msg, {icon: 5});
          }

        },
        error: function (data, status, e)//服务器响应失败处理函数
        {
          alert(e);
        }
      })
    })

//    $('#logo-upload').uploadify({
//        'swf'      : '__UPLOADIFY__/uploadify.swf',
//        'uploader' : '{:U("Auditing/Index/ajaxHeadImg")}',
//        'buttonText':' 选择文件...',
//        'onUploadSuccess':function(file,response){
//            //是否上传成功
//            var data = eval("("+response+")");
//            if(data){
//                var file_url = data.url;
////                    //将图片路径放入到隐藏域中
//                $('#head-logo').val(file_url);
//                $('#logo-preview').html('<img src="'+file_url+'" width="60px" height="60px" style="border-radius: 50%">');
//                layer.msg(data.msg, {icon: 6});
//            }else {
//                layer.msg(data.msg, {icon: 5});
//            }
//        }
//    });
</script>
</body>
</html>